package com.pug.job.task;

import cn.hutool.core.thread.ThreadUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author RenGaoshuai
 * @date 2023/7/5 10:12
 * @description
 */
@Component
@Slf4j
public class XXLJobPrintOutTask {

    /**
     * printLogOutTask改名字需要在xxljob页面配置
     * <p>
     * 业务方法返回需要返回xxljob定义好的返回类
     */

    @Value("${server.port}")
    private int port;

    @XxlJob("printLogOutTask")
    public ReturnT<String> printLogOutTask() {
        log.info("端口号：{}=======>xxljob定时任务执行开始，当前时间：{}", port, LocalDateTime.now());
        ThreadUtil.sleep(3000);
        log.info("xxljob任务执行中------");
        log.info("xxljob任务执行中------");
        log.info("xxljob任务执行中------");
        log.info("xxljob任务执行中------");
        log.info("xxljob任务执行中------");
        log.info("xxljob任务执行中------");
        log.info("xxljob任务执行中------");
        log.info("xxljob任务执行中------");
        log.info("=======>xxljob定时任务执行结束，当前时间：" + LocalDateTime.now());
        return ReturnT.SUCCESS;
    }


}
